#include <stdio.h>

int a;
int b;
int c;

void myfunc()
{
    c = a + b;
}

int main()
{
    a = 0x666;
    b = 0x777;
    myfunc();
    printf("0x%x\n", c);

	return 0;
}

/*
	0xddd
 */

#if 0

/*
 * intel
 */
0000000000001149 <myfunc>:
    1149:	f3 0f 1e fa          	endbr64 
    114d:	55                   	push   %rbp
    114e:	48 89 e5             	mov    %rsp,%rbp		// rbp=rsp
    1151:	8b 15 c5 2e 00 00    	mov    0x2ec5(%rip),%edx        # 401c <a> 	// edx=rip+0x2ec5
    1157:	8b 05 b7 2e 00 00    	mov    0x2eb7(%rip),%eax        # 4014 <b> 	// eax=rip+0x2eb7
    115d:	01 d0                	add    %edx,%eax		// eax+=edx
    115f:	89 05 b3 2e 00 00    	mov    %eax,0x2eb3(%rip)        # 4018 <c> 	// rip+0x23b3=eax
    1165:	90                   	nop
    1166:	5d                   	pop    %rbp
    1167:	c3                   	retq   

0000000000001168 <main>:
    1168:	f3 0f 1e fa          	endbr64 
    116c:	55                   	push   %rbp
    116d:	48 89 e5             	mov    %rsp,%rbp
    1170:	c7 05 a2 2e 00 00 66 	movl   $0x666,0x2ea2(%rip)        # 401c <a> 	// rip+0x2ea2=0x666
    1177:	06 00 00 
    117a:	c7 05 90 2e 00 00 77 	movl   $0x777,0x2e90(%rip)        # 4014 <b>	// rip+0x2e90=0x777
    1181:	07 00 00 
    1184:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    1189:	e8 bb ff ff ff       	callq  1149 <myfunc>		// myfunc()
    118e:	8b 05 84 2e 00 00    	mov    0x2e84(%rip),%eax        # 4018 <c>	// eax=rip+0x2e84
    1194:	89 c6                	mov    %eax,%esi		// esi=eax
    1196:	48 8d 3d 67 0e 00 00 	lea    0xe67(%rip),%rdi        # 2004 <_IO_stdin_used+0x4>	// rdi=rip+0xe67
    119d:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    11a2:	e8 a9 fe ff ff       	callq  1050 <printf@plt>	// printf(rdi, esi)
    11a7:	b8 00 00 00 00       	mov    $0x0,%eax		// eax=0
    11ac:	5d                   	pop    %rbp
    11ad:	c3                   	retq   
    11ae:	66 90                	xchg   %ax,%ax

/*
 * arm
 */
000000000040055c <myfunc>:
  40055c:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400560:	9100f000 	add	x0, x0, #0x3c			// x0=41103c
  400564:	b9400001 	ldr	w1, [x0]			// w1=[x0]
  400568:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  40056c:	9100d000 	add	x0, x0, #0x34			// x0=411034
  400570:	b9400000 	ldr	w0, [x0]			// w0=[x0]
  400574:	0b000021 	add	w1, w1, w0			// w1=w1+w0
  400578:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  40057c:	9100e000 	add	x0, x0, #0x38			// x0=411038
  400580:	b9000001 	str	w1, [x0]			// [x0]=w1
  400584:	d503201f 	nop
  400588:	d65f03c0 	ret

000000000040058c <main>:
  40058c:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!
  400590:	910003fd 	mov	x29, sp
  400594:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  400598:	9100f000 	add	x0, x0, #0x3c			// x0=41103c
  40059c:	5280ccc1 	mov	w1, #0x666                 	// #1638
  4005a0:	b9000001 	str	w1, [x0]			// [x0]=0x666
  4005a4:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  4005a8:	9100d000 	add	x0, x0, #0x34			// x0=411034
  4005ac:	5280eee1 	mov	w1, #0x777                 	// #1911
  4005b0:	b9000001 	str	w1, [x0]			// [x0]=0x777
  4005b4:	97ffffea 	bl	40055c <myfunc>			// myfunc()
  4005b8:	b0000080 	adrp	x0, 411000 <__libc_start_main@GLIBC_2.17>
  4005bc:	9100e000 	add	x0, x0, #0x38			// x0=411038
  4005c0:	b9400001 	ldr	w1, [x0]			// w1=[x0]
  4005c4:	90000000 	adrp	x0, 400000 <_init-0x3e8>
  4005c8:	911a4000 	add	x0, x0, #0x690			// x0=400690
  4005cc:	97ffffa1 	bl	400450 <printf@plt>		// printf(x0, w1)
  4005d0:	52800000 	mov	w0, #0x0                   	// #0
  4005d4:	a8c17bfd 	ldp	x29, x30, [sp], #16
  4005d8:	d65f03c0 	ret
  4005dc:	00000000 	.inst	0x00000000 ; undefined

#endif
